package learnJava1.JDBC.CRUDUtils;

import learnJava1.JDBC.domain.JDBCUnits;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class JDBCUpate {
    public static void update(String sql, Object ... obj){
        Connection c = null;
        PreparedStatement pstmt = null;
        try{
            c = JDBCUnits.getConnectino();
            pstmt = c.prepareStatement(sql);

            for(int i=0;i< obj.length;i++){
                pstmt.setObject(i+1,obj[i]);
            }

            pstmt.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            JDBCUnits.close(c,pstmt);
        }
    }
}
